package cn.chiship.framework.upms.biz.system.service.impl;

import cn.chiship.framework.upms.biz.system.pojo.dto.UpmsFeedbackReplyDto;
import cn.chiship.sdk.core.base.BaseResult;
import cn.chiship.sdk.core.util.StringUtil;
import cn.chiship.sdk.framework.base.BaseServiceImpl;
import cn.chiship.framework.upms.biz.system.mapper.UpmsFeedbackMapper;
import cn.chiship.framework.upms.biz.system.entity.UpmsFeedback;
import cn.chiship.framework.upms.biz.system.entity.UpmsFeedbackExample;
import cn.chiship.framework.upms.biz.system.service.UpmsFeedbackService;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

/**
 * 意见反馈业务接口实现层
 * 2022/6/9
 *
 * @author lijian
 */
@Service
public class UpmsFeedbackServiceImpl extends BaseServiceImpl<UpmsFeedback, UpmsFeedbackExample> implements UpmsFeedbackService {

    @Resource
    UpmsFeedbackMapper upmsFeedbackMapper;

    @Override
    public BaseResult reply(UpmsFeedbackReplyDto upmsFeedbackReplyDto, String replyPeople) {
        UpmsFeedback upmsFeedback = upmsFeedbackMapper.selectByPrimaryKey(upmsFeedbackReplyDto.getId());
        if (StringUtil.isNull(upmsFeedback)) {
            return BaseResult.error("记录不存在!");
        }
        upmsFeedback.setIsReply(Byte.valueOf("1"));
        upmsFeedback.setReplyContent(upmsFeedbackReplyDto.getReplyContent());
        upmsFeedback.setReplyPeople(replyPeople);
        upmsFeedback.setReplyTime(System.currentTimeMillis());
        return super.updateByPrimaryKeySelective(upmsFeedback);
    }

}
